# -*- coding: utf-8 -*-
from flask_script import Server, Command

from application import manager

from www import *

from jobs.launcher import runJob

# web server
manager.add_command("runserver", Server(host="0.0.0.0", use_debugger=True, use_reloader=True))


# create_table
@Command
def create_all():
	from application import db
	from common.models.user import User
	db.create_all()


manager.add_command("create_all", create_all)

# job 框架
manager.add_command("runjob", runJob)


def main():
	manager.run()


if __name__ == "__main__":
	# app.run( host = "0.0.0.0",debug=True )
	try:
		import sys

		sys.exit(main())
	except Exception as e:
		import traceback

		traceback.print_exc()
